/**
 * 线下专窗 api js
 */
import request from "@/utils/request";

const baseURL = process.env.VUE_APP_BASE_API;

/**
 *
 * @param {*} data
 * 保存线下专窗数据
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/specialWindowSystem/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 分页查询列表数据
 * @param {*} params
 */
export function pageList(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/specialWindowSystem/noAuthpageList",
    method: "post",
    params: params
  });
}

/**
 * 通过主键获取对象数据
 * @param {*} id
 */
export function getOne(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/specialWindowSystem/getOne/" +
      id,
    method: "get"
  });
}

/**
 * 通过主键删除数据
 * @param {*} id
 */
export function del(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/specialWindowSystem/delete/" +
      id,
    method: "delete"
  });
}

/**
 * 更新发布状态
 * @param {*} id
 * @param {*} authorize
 */
export function updateEnableFlag(id, enableFlag) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/specialWindowSystem/updateEnableFlag",
    method: "get",
    params: {
      oid: id,
      enableFlag
    }
  });
}

export function queryRegionManageTree(regionOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/common/queryRegionManageTree?regionOid=" +
      regionOid,
    method: "get"
  });
}

export function getDistrictSpecialWinTree() {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/common/getDistrictSpecialWinTree",
    method: "get"
  });
}

/**
 * 根据登录人查询拥有的专窗系统，有分页
 * @param {*} data
 */
export function queryUserSpecialWinSystem(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/specialWindowSystem/queryUserSpecialWinSystem",
    method: "get",
    params: params
  });
}
